package com.itheima.web.controller.stat;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.cargo.ContractProductService;
import com.itheima.service.system.ISysLogService;
import com.itheima.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/stat")
public class StatController extends BaseController {

    @Reference
    private ContractProductService contractProductService;

    @Autowired
    private ISysLogService logService;

    //http://localhost:8088/export_manager_web_war_exploded/stat/toCharts.do?chartsType=factory

    @RequestMapping("/toCharts")
    public String toCharts(String chartsType){
        return "stat/stat-"+chartsType;
    }

    @RequestMapping(value = "/findFactoryData",name = "前往厂家销售额统计图")
    public @ResponseBody List findFactoryData (){
        return contractProductService.findFactoryData(getCurrentUserCompanyId());
    }

    @RequestMapping(value = "/findSellData",name = "前往销售排行柱状图")
    public @ResponseBody List findSellData (){
        return contractProductService.findSellData(getCurrentUserCompanyId());
    }

    @RequestMapping(value = "/findOnlineData",name = "前往系统访问压力折线状图")
    public @ResponseBody List findOnlineData (){
        return logService.findOnlineData();
    }
}
